#include <bits/stdc++.h>
using namespace std;

int ma[201][201];
int di[] = {-1, 1, 0, 0};
int dj[] = {0, 0, -1, 1};

void search(int i, int j) {
  ma[i][j] = 0;
  for (int k = 0; k < 4; k++) {
    int ni = i + di[k];
    int nj = j + dj[k];
    if (ma[ni][nj] == 1)
      search(ni, nj);
  }
}
int main() {
  int n, m;
  cin >> n >> m;

  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      char c;
      cin >> c;
      if (c == '.')
        ma[i][j] = 1;
    }
  }
  int t = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (ma[i][j] == 1) {
        t++;
        search(i, j);
      }
    }
  }
  cout << t << endl;
  return 0;
}